#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 30 23:06:16 2024

@author: liqingsimac
"""
import numpy as np
import matplotlib.pyplot as plt
a=2; b=1; tau=5; m=20
x_initial=0.5 
t_final=100 
h=0.1 
d=50 
N=(tau+t_final)*10+1 
t=np.linspace(-tau,t_final,N) 
x=np.zeros_like(t) 
x[0:d+1]=x_initial 

s=np.zeros_like(t) 
for k in range(d,len(t)-1):
    s[k]=a*x[k-d]/(1+x[k-d]**m)-b*x[k]
    x[k+1]=x[k]+h*s[k]

fig = plt.figure()
ax = fig.add_subplot(121)
ax.plot(t,x,'b--')
bx = fig.add_subplot(122)
bx.plot(x[0:N-5],x[5:N],'--')
fig.subplots_adjust(hspace=0.5, wspace=0.5)

'''
import numpy as np
import matplotlib.pyplot as plt
a=2; b=1; tau=5; m=10 #模型参数
x_initial=0.5 #初始值
t_final=100 # 终点时刻
h=0.1 #步长
d=50 #时刻零在时间[-5,100] 的等分点的编号
N=(tau+t_final)*10+1 #时间等分点的总数
t=np.linspace(-tau,t_final,N) #时间分点
x=np.zeros_like(t) #存放函数值
x[0:d+1]=x_initial #函数赋初始值

s=np.zeros_like(t) #存放方程右端的值
for k in range(d,len(t)-1):
    s[k]=a*x[k-d]/(1+x[k-d]**m)-b*x[k]
    x[k+1]=x[k]+h*s[k]

plt.plot(t,x,'b--')
'''
